﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Collections.Generic;

public partial class TaoBaoApi_TB_ShangDian : System.Web.UI.Page
{
    protected void Page_PreInit(object sender, EventArgs e)
    {
        Page.Theme = BLL.Common.GetWSMThemes();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //check(暂无)

        if (!IsPostBack)
        {  
            Bind();
        }
    }
    void Bind()
    {        
        List<Model.TaoBao.TB_SHANGDIAN> shopList = new BLL.TaoBao.TB_SHANGDIAN().GetAllList();
        gvList.DataSource = shopList;
        gvList.DataBind();
    }  
    public void Add()
    {
        Response.Redirect("TB_Shangdian_Edit.aspx");
    }
    public void Update()
    {
        List<int> s = new List<int>();
        foreach (GridViewRow row in gvList.Rows)
        {
            CheckBox chk = (CheckBox)row.FindControl("chkOne");
            if (chk != null && chk.Checked)
                s.Add(Convert.ToInt32(row.Cells[1].Text));
        }
        if (s.Count > 0)
        {
            Response.Redirect("TB_Shangdian_Edit.aspx?code=" + s[0].ToString());
        }
        else
        {
            new TBCommon().ShowMessage(Page, "请选择一条需要编辑的记录");            
        }
    }
    public void Delete()
    {
        List<int> s = new List<int>();
        foreach (GridViewRow row in gvList.Rows)
        {
            CheckBox chk = (CheckBox)row.FindControl("chkOne");
            if (chk != null && chk.Checked)
                s.Add(Convert.ToInt32(row.Cells[1].Text));
        }
        if (s.Count == 0)
        {
            new TBCommon().ShowMessage(Page, "请选择一条需要编辑的记录");
            return;
        }
        new BLL.TaoBao.TB_SHANGDIAN().Delete(s);
        //Share.InsertLog("200300104", "00003");
        Response.Redirect("TB_Shangdian.aspx");
    }
    protected void gvList_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gvList.PageIndex = e.NewPageIndex;
        Bind();
    }
    protected void chkAll_OnCheckedChanged(object sender, EventArgs e)
    {
        new TBCommon().chk_OnCheckedChanged(sender, e, gvList, "chkOne");
    }
    protected void gvList_RowCreated(object sender, GridViewRowEventArgs e)
    {
        new TBCommon().gv_RowCreated(sender, e, gvList, Page);
    }
    protected string GetDDLYName(object o)
    {
        if (o is DBNull || o == null || o.ToString().Length == 0)
            return null;
        Model.ORDERFROM of = new BLL.ORDERFROM().GetModel(o.ToString());
        if (of != null)
            return of.OF_NAME;
        return null;
    }
}
